package com.qf.controller;

import com.alibaba.fastjson.JSON;
import com.qf.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
杨威
2021/9/24
8:36
*/
@WebServlet("/login3")
public class LonginController3 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = JSON.parseObject(request.getInputStream(), User.class);
        System.out.println(user);
        user.setUsername("tom");
        String s = JSON.toJSONString(user);
        response.getWriter().println(s);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
